
package net.lab0.fractal.conf;


import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.InvalidPropertiesFormatException;

import org.apache.log4j.Logger;

import net.lab0.tools.cfg.Configuration;


@SuppressWarnings("serial")
public class PathConfiguration
extends Configuration
{
    public PathConfiguration(File file, boolean load)
    throws InvalidPropertiesFormatException, FileNotFoundException, IOException
    {
        super(file, load);
    }
    
    public PathConfiguration(Configuration configuration)
    {
        super(configuration);
    }
    
    // the main log folder
    
    private File LogFolder;
    
    public File getLogFolder()
    {
        if (LogFolder == null)
        {
            LogFolder = getAsFile("LogFolder");
            if (LogFolder == null)
            {
                resetLogFolder();
            }
        }
        
        return LogFolder;
    }
    
    public void setLogFolder(File LogFolder)
    {
        this.LogFolder = LogFolder;
        setAsFile("LogFolder", LogFolder);
    }
    
    public void resetLogFolder()
    {
        setLogFolder(new File("./log"));
    }
    
    //
    
    private String       LogConfigurationFilePath;
    private final String LogConfigurationFilePathKey = "LogConfigurationFilePath";
    
    public String getLogConfigurationFilePath()
    {
        if (LogConfigurationFilePath == null)
        {
            LogConfigurationFilePath = getAsString(LogConfigurationFilePathKey);
            if (LogConfigurationFilePath == null)
            {
                Logger.getRootLogger().warn("resetting LogConfigurationFilePath");
                resetLogConfigurationFilePath();
            }
        }
        
        return LogConfigurationFilePath;
    }
    
    public void setLogConfigurationFilePath(String LogConfigurationFilePath)
    {
        this.LogConfigurationFilePath = LogConfigurationFilePath;
        setAsString(LogConfigurationFilePathKey, LogConfigurationFilePath);
    }
    
    public void resetLogConfigurationFilePath()
    {
        setLogConfigurationFilePath("./cfg/log4j.xml");
    }
    
    //
    
    private File         DefaultMandelbrotQuadTreeSaveFolder;
    private final String DefaultMandelbrotQuadTreeSaveFolderKey = "DefaultMandelbrotQuadTreeSaveFolder";
    
    public File getDefaultMandelbrotQuadTreeSaveFolder()
    {
        if (DefaultMandelbrotQuadTreeSaveFolder == null)
        {
            DefaultMandelbrotQuadTreeSaveFolder = getAsFile(DefaultMandelbrotQuadTreeSaveFolderKey);
            if (DefaultMandelbrotQuadTreeSaveFolder == null)
            {
                resetDefaultMandelbrotQuadTreeSaveFolder();
            }
        }
        
        return DefaultMandelbrotQuadTreeSaveFolder;
    }
    
    public void setDefaultMandelbrotQuadTreeSaveFolder(File DefaultMandelbrotQuadTreeSaveFolder)
    {
        this.DefaultMandelbrotQuadTreeSaveFolder = DefaultMandelbrotQuadTreeSaveFolder;
        setAsFile(DefaultMandelbrotQuadTreeSaveFolderKey, DefaultMandelbrotQuadTreeSaveFolder);
    }
    
    public void resetDefaultMandelbrotQuadTreeSaveFolder()
    {
        setDefaultMandelbrotQuadTreeSaveFolder(new File("R:\\dev\\buddha2\\tree"));
    }
}
